package com.cloudcc.mobile.parser;

import org.json.JSONException;
import org.json.JSONObject;

import com.cloudcc.mobile.entity.ImageInfo;
import com.cloudcc.mobile.util.Tools;

public class ImageParser {

	/**
	 * 解析查询的客户
	 * @param jsonString
	 * @return
	 */
	public  static ImageInfo getImageInfo(String jsonString){
		ImageInfo image=new ImageInfo();
		try {
			JSONObject obj=new JSONObject(jsonString);
			image.setResult(obj.getBoolean("result"));
			image.setReturnCode(obj.getString("returnCode"));
			image.setReturnInfo(obj.getString("returnInfo"));
			JSONObject o=obj.getJSONObject("data");
			String imgid=o.getString("imgId");
			image.setImgId(imgid);
		} catch (JSONException e) {
			Tools.handle(e);
		}
		return image;
	}

	/**
	 * 解析"带权限"插入返回数据
	 */
	public static boolean getResult(String jsonString){
		boolean result = false;
		try {
			JSONObject obj=new JSONObject(jsonString);
			result=obj.getBoolean("result");
		} catch (JSONException e) {
			Tools.handle(e);
		}
		return result;
	}
	/**
	 * 解析修改返回数据
	 */
	public static boolean getUpResult(String jsonString){
		boolean result=false;
		try {
			JSONObject obj=new JSONObject(jsonString);
			result=obj.getBoolean("result");
		} catch (Exception e) {
			Tools.handle(e);
		}
		return result;
	}
	/**
	 * 解析 插入图片返回的数据
	 */
	public static String getManyImageId(String jsonString){
		
		return null;
	}
}
